package com.jtx.miaoah2.Cache;

import com.jtx.miaoah2.Common.RedisConstants;
import com.jtx.miaoah2.Model.goods.DO.SkGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisZSetCommands;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author 季台星
 * @Date 2023 07 27 15 48
 */
@Component
public class SkGoodsCache {
    @Autowired
    private StringRedisTemplate redisTemplate;


    public List<SkGoods> getSkGoodsList(List<Long> ids){
        Set<Object> idsSet = ids.stream().map(ele -> String.valueOf(ele)).collect(Collectors.toSet());
        Set<Object> keys = redisTemplate.opsForHash().keys(RedisConstants.GOODS_INFO);
        //对两个Set集合取差集
        List<Object> noRedisIs = idsSet.stream().filter(id -> keys.contains(id)).collect(Collectors.toList());
        //寻找没有存在redis中的key
        return null;
    }
}
